package per.liuchengyin.alipay.letter;


import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import per.liuchengyin.alipay.pojo.OmsOrder;
import per.liuchengyin.alipay.service.OrderService;

import java.io.IOException;

//@Component
public class DeadConsumer {
    @Autowired
    private OrderService orderService;

    @RabbitListener(queues = "priceLetterQueue")
    public void receiveBizMsg1(Message message, Channel channel) throws IOException {
        System.out.println("收到<<<死信>>>消息1：" + new String(message.getBody()));
        String s = new String(message.getBody());
        System.out.println(s+"1111111");
        s=s.substring(1,s.length()-1);
        OmsOrder order=orderService.sele(s);
        if(order.getStatus()==0){
            order.setStatus(5);
            order.setOrderSn(s);
            int i=orderService.update(order);
            channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);        }
        else{
                System.out.println(order);
                System.out.println("支付成功");
                channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
        }
    }
}
